Skip to content

EditSubscriptionScreen wrongly goes into edited state#664

Merged
ArnyminerZ merged 10 commits into
devfrom
661-editsubscriptionscreen-wrongly-goes-into-edited-state
Sep 1, 2025
Merged

EditSubscriptionScreen wrongly goes into edited state#664
ArnyminerZ merged 10 commits into
devfrom
661-editsubscriptionscreen-wrongly-goes-into-edited-state

Conversation

@ArnyminerZ
Copy link
Copy Markdown
Member

Purpose

The edit subscription screen is misdetecting changes as dirty.

Short description

  • Fix typo.

That was a tough one to spot.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@ArnyminerZ ArnyminerZ self-assigned this Aug 22, 2025
@ArnyminerZ ArnyminerZ added the bug label Aug 22, 2025
@ArnyminerZ ArnyminerZ linked an issue Aug 22, 2025 that may be closed by this pull request
@ArnyminerZ ArnyminerZ marked this pull request as ready for review August 22, 2025 15:08
@ArnyminerZ ArnyminerZ requested a review from Copilot August 22, 2025 15:09

This comment was marked as outdated.

Copy link
Copy Markdown
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to say that fixes it. But it still happens :/ And I totally get that this is hard to debug. I feel like the state of the whole code base is not good, because we mix so many approaches at the moment.

@ArnyminerZ ArnyminerZ changed the title EditSubscriptionScreen wrongly goes into edited state EditSubscriptionScreen wrongly goes into edited state Aug 26, 2025
@ArnyminerZ
Copy link
Copy Markdown
Member Author

ArnyminerZ commented Aug 26, 2025

Okay, now it should be good. The thing was that all initialSubscription, initialCredential and initialRequiresAuthValue were regular variables, and as such, the UI was not updating when they change. Since they were initialized after all the subscriptionSettingsUseCase.set* calls, if the UI was updated quickly, their value was not correctly retrieved upon refreshing inputValid. I've moved them, and now it's good. Please test and see

Edit: not working... I'll give it another try

@ArnyminerZ ArnyminerZ requested review from sunkup and removed request for sunkup August 26, 2025 12:57
@ArnyminerZ ArnyminerZ requested a review from sunkup August 26, 2025 13:22
Copy link
Copy Markdown
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! It's always pleasing to see when code can be deleted. We should also update the kdoc though.

At some point we should use flows instead of LaunchedEffect or the view model init method, but for now let's get this working as is. 👍

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ requested a review from Copilot August 27, 2025 13:35
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the EditSubscriptionScreen was incorrectly detecting changes as dirty due to a typo in property comparison. The fix involves replacing reactive flow collection with direct data fetching and consolidating the subscription state initialization logic.

  • Replace flow-based subscription loading with direct database query to avoid state synchronization issues
  • Consolidate subscription and credential initialization into a single update() method
  • Fix property comparison for dirty state detection by using computed property instead of stored variable

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
EditSubscriptionScreen.kt Remove flow collection and use direct property access for subscription data
SubscriptionSettingsUseCase.kt Add update() method to initialize UI state from subscription and credential data
EditSubscriptionModel.kt Replace flow-based loading with direct query and fix dirty state detection logic
SubscriptionsDao.kt Add non-flow method to get subscription with credentials by ID

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread app/src/main/java/at/bitfire/icsdroid/model/EditSubscriptionModel.kt Outdated
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
…edited-state

# Conflicts:
#	app/src/main/java/at/bitfire/icsdroid/model/EditSubscriptionModel.kt
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ requested a review from sunkup August 27, 2025 13:40
@sunkup
Copy link
Copy Markdown
Member

sunkup commented Aug 28, 2025

Ready to merge when you want to 👍

@ArnyminerZ ArnyminerZ merged commit 9866667 into dev Sep 1, 2025
7 checks passed
@ArnyminerZ ArnyminerZ deleted the 661-editsubscriptionscreen-wrongly-goes-into-edited-state branch September 1, 2025 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EditSubscriptionScreen wrongly goes into edited state

3 participants